Skip to content

Conversation

@itsmeichigo
Copy link
Contributor

@itsmeichigo itsmeichigo commented Jan 5, 2023

Closes #8550

Description

This PR updates all mappers related to orders endpoints: ReportOrderTotalsMapper, OrderListMapper, OrderMapper, OrderNoteMapper to parse contents without the data envelope.

All endpoints with paths /orders, /notes and /reports/orders/totals are enabled for REST API requests.

Testing instructions

  • Enable the feature flag applicationPasswordAuthenticationForSiteCredentialLogin and build the app.
  • Log out of the app or skip onboarding if needed.
  • On the prologue screen, select Enter your site address and input the address of a self-hosted store.
  • Enter correct site credentials to log in.
  • When the login succeeds, navigate to the Orders tab. Try creating, updating, loading orders. Everything should work properly.

Please feel free to test again by logging in with a WPCom account. All order-related features should work too.

Screenshots

N/A


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@itsmeichigo itsmeichigo added type: task An internally driven task. feature: order details Related to order details. feature: order list Related to the order list. status: feature-flagged Behind a feature flag. Milestone is not strongly held. feature: order creation All tasks related to creating an order labels Jan 5, 2023
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 5, 2023

You can test the changes from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr8554-2f9d67d on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@peril-woocommerce
Copy link

peril-woocommerce bot commented Jan 6, 2023

Warnings
⚠️ PR is not assigned to a milestone.
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS

@itsmeichigo itsmeichigo marked this pull request as ready for review January 6, 2023 03:17
@jaclync jaclync self-assigned this Jan 6, 2023
Copy link
Contributor

@jaclync jaclync left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :shipit: there are some failures from related entities like refunds, products, and countries, I'm sure they will be handled separately.

return mapOrders(from: "orders-load-all")
}

/// Returns the OrderListMapper output upon receiving `orders-load-all-without-data`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit:

Suggested change
/// Returns the OrderListMapper output upon receiving `orders-load-all-without-data`
/// Returns the [Order] output upon receiving `orders-load-all-without-data`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 7848519.

return mapOrder(from: "order")
}

/// Returns the OrderMapper output upon receiving `order-without-data`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit:

Suggested change
/// Returns the OrderMapper output upon receiving `order-without-data`
/// Returns the Order output upon receiving `order-without-data`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 4d36b6c.

return mapNotes(from: "order-notes")
}

/// Returns the OrderNotesMapper output upon receiving `order-notes-without-data`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit:

Suggested change
/// Returns the OrderNotesMapper output upon receiving `order-notes-without-data`
/// Returns the [OrderNote] output upon receiving `order-notes-without-data`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in f0f2944.

let statuses = try? mapper.map(response: data)

// Then
XCTAssertNotNil(mapper)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reasons asserting on the mapper? the mapper initialization doesn't seem nullable 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant indeed 😅 Removed in 6dad597.

}

// When
let statuses = try? mapper.map(response: data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can probably make the result non-nil by using try XCTUnwrap

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also updated in 6dad597.

private extension ReportOrderTotalsMapperTests {
/// Returns the CustomerMapper output upon receiving `filename` (Data Encoded)
///
func mapStatus(from filename: String) throws -> [OrderStatus] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: is this meant to be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also redundant - removed in 2f9d67d 👍

@itsmeichigo itsmeichigo added this to the 11.8 milestone Jan 6, 2023
@itsmeichigo itsmeichigo enabled auto-merge January 6, 2023 08:11
@spencertransier spencertransier modified the milestones: 11.8, 11.9 Jan 7, 2023
@itsmeichigo itsmeichigo merged commit f969f6e into trunk Jan 9, 2023
@itsmeichigo itsmeichigo deleted the feat/8550-orders-migrate branch January 9, 2023 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: order creation All tasks related to creating an order feature: order details Related to order details. feature: order list Related to the order list. status: feature-flagged Behind a feature flag. Milestone is not strongly held. type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

REST API: Migrate Orders endpoints

5 participants